﻿@{
    ViewData["Title"] = "HouseUpdate";
    Layout = null;
}
<html>
<head>
    <link href="~/layui/css/layui.css" rel="stylesheet" />
    <script src="~/layui/layui.js"></script>
    <script src="~/libs/jquery/jquery.js"></script>
</head>
<body>
    <form class="layui-form layui-form-pane" action="">
        <div class="layui-row">
            <div class="layui-col-xs6">
                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">仓库编码</label>
                    <div class="layui-input-block">
                        <input type="text" name="WarehouseCode" id="WarehouseCode" autocomplete="off" placeholder="请输入" disabled lay-verify="required" class="layui-input">
                        <button class="layui-btn layui-btn-normal" id="test-btn-other">随机生成</button>
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">仓库名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="WarehouseName" id="WarehouseName" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">仓库面积</label>
                    <div class="layui-input-block">
                        <input type="text" name="Area" id="Area" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label" style="width: 100px;">负责人</label>
                    <div class="layui-input-block">
                        <input type="text" name="Charge" id="Charge" autocomplete="off" placeholder="请输入" lay-verify="required" class="layui-input">
                    </div>
                </div>
            </div>

            <div class="layui-col-xs6">
                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width: 100px;">仓库位置</label>
                    <div class="layui-input-block">
                        <textarea name="Location" id="Location" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label" style="width: 100px;">备注</label>
                    <div class="layui-input-block">
                        <textarea name="Remark" id="Remark" placeholder="请输入内容" class="layui-textarea"></textarea>
                    </div>
                </div>


            </div>

            <div class="layui-form-item" style="text-align: center;">
                <div class="layui-input-block">
                    <button class="layui-btn" type="button" lay-submit lay-filter="updateHouse">修改</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>

        </div>
    </form>

    <script>
        layui.use(['form', 'laydate'], function () {
            var form = layui.form;
            var layer = layui.layer;
            var $ = layui.$;
            var updatehouse = JSON.parse(localStorage.getItem("updatehouse"));
            console.log(updatehouse);

            $("[name=WarehouseCode]").val(updatehouse.WarehouseCode)
            $("[name=WarehouseName]").val(updatehouse.WarehouseName)
            $("[name=Location]").val(updatehouse.Location)
            $("[name=Area]").val(updatehouse.Area)
            $("[name=Charge]").val(updatehouse.Charge)
            //  //form.render('select');

            $("[name=Remark]").val(updatehouse.Remark)
            // 提交事件
            form.on('submit(updateHouse)', function (data) {
                data = data.field;
                console.log(data)
                updatehouse.WarehouseCode = data.WarehouseCode;
                updatehouse.WarehouseName = data.WarehouseName;
                updatehouse.Location = data.Location;
                updatehouse.Area = data.Area;
                updatehouse.Charge = data.Charge;
                updatehouse.Remark = data.Remark;
               

                $.get("/QiData/UpdateWareHouse", updatehouse,
                    res => {
                        if (res) {
                            layer.msg('修改仓库成功', {
                                icon: 1,
                                time: 1000
                            }, function () {
                                var index = parent.layer.getFrameIndex(window.name);
                                parent.layer.close(index);
                                window.location = '/QiData/HouseShow';
                            });
                        }
                        else {
                            layer.msg('修改仓库失败！', {
                                icon: 1,
                                time: 1000
                            });
                        }
                    }
                )
            });
        });
    </script>


</body>

</html>
